--[[BHVERSION=1.0]]

local BB = { };

if ( SERVER ) then return end -- We only want this to work clientside
lblue = Color(0,150,255)
local BH = { }; --bluehawk is mostly blue bot(renamed to bh) with some extra coding from sethhack, hera, isis, and neonhack(2010)

BH.CustomPrefix = "Hawk"; --change it to whatever you want, nil for random

function BH.RandomString( len, numbers, special )
	local chars = "abcdlmnopJKLMNOPQRSTABCDEFqefghijkrstuvwxyzGHIUVWXYZ"..(numbers == true && "1904238567" or "")..(special == true && "!?@#$%^&+={}:;'\"<>*[](),.-|\\" or "");
	local result = "";
	
	if (len < 1) then
		len = math.random( 10, 20 );
	end
	
	for i = 1, len do
		result = result..string.char( string.byte( chars, math.random( 1, string.len( chars ) ) ) );
	end
	
	return tostring( result );
end

function BH.Bypass()
-- DAZ anti cheat
for i = 100, 100000 do
hook.Remove("Think", tostring( i ))
end

-- stronghold anti-cheat
hook.Remove("Think", "PlayerInfoThing")

-- gmodz anti cheat
timer.Destroy("AntiCheatTimer")
timer.Destroy("testing123")
timer.Destroy( "AntiCheatTimer" )
local OriginalGetConVarNumber = GetConVarNumber;

function GetConVarNumber( name )
	if ( name == "sv_allowcslua" ) then
		return 0;
	else
		return OriginalGetConVarNumber( name );
	end
end
-------------------

-- sammy servers anti cheat
hook.Add("Think", "sh_menu", function()
return true
end)
hook.Remove("Think", "sh_menu")
end


BH.MetaPlayer = FindMetaTable( "Player" );
BH.CreateClientConVar = CreateClientConVar;

local function CreateClientConVar( cvarname, default, save, onmenu )
	BH.CreateClientConVar( cvarname, default, save, false );
	return {cvar = GetConVar( cvarname ), OnMenu = onmenu, name = cvarname, main = string.find( cvarname, "enable" )};
end

BH.RandomPrefix = BH.CustomPrefix or BH.RandomString( math.random( 5, 8 ), false );
BH.require = require;
BH.DeadPlayers = { };
BH.Traitors = { };
BH.TWeaponsFound = { };

BH.espbones = { --this really sucks
{ S = "ValveBiped.Bip01_Head1", E = "ValveBiped.Bip01_Neck1" },
{ S = "ValveBiped.Bip01_Neck1", E = "ValveBiped.Bip01_Spine4" },
{ S = "ValveBiped.Bip01_Spine4", E = "ValveBiped.Bip01_Spine2" },
{ S = "ValveBiped.Bip01_Spine2", E = "ValveBiped.Bip01_Spine1" },
{ S = "ValveBiped.Bip01_Spine1", E = "ValveBiped.Bip01_Spine" },
{ S = "ValveBiped.Bip01_Spine", E = "ValveBiped.Bip01_Pelvis" },
{ S = "ValveBiped.Bip01_Spine4", E = "ValveBiped.Bip01_L_UpperArm" },
{ S = "ValveBiped.Bip01_L_UpperArm", E = "ValveBiped.Bip01_L_Forearm" },
{ S = "ValveBiped.Bip01_L_Forearm", E = "ValveBiped.Bip01_L_Hand" },
{ S = "ValveBiped.Bip01_Spine4", E = "ValveBiped.Bip01_R_UpperArm" },
{ S = "ValveBiped.Bip01_R_UpperArm", E = "ValveBiped.Bip01_R_Forearm" },
{ S = "ValveBiped.Bip01_R_Forearm", E = "ValveBiped.Bip01_R_Hand" },
{ S = "ValveBiped.Bip01_Pelvis", E = "ValveBiped.Bip01_L_Thigh" },
{ S = "ValveBiped.Bip01_L_Thigh", E = "ValveBiped.Bip01_L_Calf" },
{ S = "ValveBiped.Bip01_L_Calf", E = "ValveBiped.Bip01_L_Foot" },
{ S = "ValveBiped.Bip01_L_Foot", E = "ValveBiped.Bip01_L_Toe0" },
{ S = "ValveBiped.Bip01_Pelvis", E = "ValveBiped.Bip01_R_Thigh" },
{ S = "ValveBiped.Bip01_R_Thigh", E = "ValveBiped.Bip01_R_Calf" },
{ S = "ValveBiped.Bip01_R_Calf", E = "ValveBiped.Bip01_R_Foot" },
{ S = "ValveBiped.Bip01_R_Foot", E = "ValveBiped.Bip01_R_Toe0" },
}

BH.PerpWeed = { "ent_pot", "ent_pot_pots" }; --yay perp
BH.PerpItems = { "ent_item_items", "ent_item" }; --yay more perp
BH.PerpCocaine = { "ent_coca_cohz" }; --yay perp
BH.zMod = { "canopener" }; --yay zmod

BH.zModWeapons = { --yay zmod
"zmweap_glock20",
"zmweap_ak47",
"zmweap_deagle",
"zmweap_famas",
"zmweap_r870",
"zmweap_machete",
---------------
"zweap_deagle",
"zweap_machete",
"zweap_r870",
"zweap_famas",
"zweap_ak47", 
"zweap_glock20",
};

BH.GmodZFood = { -- all food
"orange",
"milk",
"water",
"soda",
"melon",
"banana",
"literwater",
"beans",
"fastfood",
}

BH.GmodZItem = { -- all food
"gmodz_item",
}


BH.PrinterTable = { --yay rp
"reg_money_printer",
"money_printer",
"platinum_printer",
"golden_printer",
"normal_money_printer",
"topaz_money_printer",
"zz_money_printer",
"money_printer_commercial",
"money_printer_industrial", 
"spawned_weapon",
"spawned_money",
"spawned_shipment",
"amethyst_money_printer",
"emerald_money_printer",
"ruby_money_printer",
"sapphire_money_printer",
"golden_money_printer",
"nuclear_money_printer",};

BH.Recoils = { };
BH.Admins = { };
BH.spectators = { };
BH.RandomHooks = { hook = { }, name = { } };
BH.ply = LocalPlayer;
BH.players = player.GetAll;
BH.Target = nil;
BH.mouse1 = false;
BH.AimbotKeyDown = false;
BH.CVARS = {Bools = { }, Numbers = { }};
BH.CVARS.Bools["Aimbot"] = CreateClientConVar( BH.RandomPrefix.."_aimbot_enabled", "1", true, true );
BH.CVARS.Bools["Random Aimspot"] = CreateClientConVar( BH.RandomPrefix.."_aimbot_randspot", "1", true, true );
BH.CVARS.Bools["Aim on key"] = CreateClientConVar( BH.RandomPrefix.."_aim_on_key", "1", true, true );
BH.CVARS.Bools["Aim on mouse1"] = CreateClientConVar( BH.RandomPrefix.."_aim_on_mouse", "0", true, true );
BH.CVARS.Bools["Ignore LOS"] = CreateClientConVar( BH.RandomPrefix.."_aim_ignore_los", "0", true, true );
BH.CVARS.Numbers["Aim Distance"] = CreateClientConVar( BH.RandomPrefix.."_aimbot_max_distance", "5000", true, true );
BH.CVARS.Numbers["Max Angle"] = CreateClientConVar( BH.RandomPrefix.."_aimbot_max_angle", "30", true, true );
BH.CVARS.Bools["Aim at team mates"] = CreateClientConVar( BH.RandomPrefix.."_aimbot_friendly_fire", "1", true, true );
BH.CVARS.Bools["Ignore admins"] = CreateClientConVar( BH.RandomPrefix.."_aimbot_admins", "0", true, true );
BH.CVARS.Bools["Aim at steam friends"] = CreateClientConVar( BH.RandomPrefix.."_aimbot_steam_friends", "0", true, true );
BH.CVARS.Bools["ESP"] = CreateClientConVar( BH.RandomPrefix.."_esp_enabled", "1", true, true );
BH.CVARS.Numbers["ESP: Distance"] = CreateClientConVar( BH.RandomPrefix.."_esp_distance", "7000", true, true );
BH.CVARS.Bools["ESP: Show Adminlist"] = CreateClientConVar( BH.RandomPrefix.."_esp_show_adminlist", "1", true, true );
BH.CVARS.Bools["ESP: Show health"] = CreateClientConVar( BH.RandomPrefix.."_esp_show_health", "1", true, true );
BH.CVARS.Bools["ESP: Show weapon"] = CreateClientConVar( BH.RandomPrefix.."_esp_show_weapon", "1", true, true );
BH.CVARS.Bools["ESP: Show name"] = CreateClientConVar( BH.RandomPrefix.."_esp_show_name", "1", true, true );
BH.CVARS.Bools["ESP: Show Skeleton"] = CreateClientConVar( BH.RandomPrefix.."_esp_skeleton", "0", true, true );
BH.CVARS.Bools["ESP: Show Weapons"] = CreateClientConVar( BH.RandomPrefix.."_esp_weapons", "1", true, true );
BH.CVARS.Bools["ESP: Show Money Printers"] = CreateClientConVar( BH.RandomPrefix.."_esp_show_money", "1", true, true );
BH.CVARS.Bools["Drug Dealer"] = CreateClientConVar( BH.RandomPrefix.."_dd", "1", true, true );
BH.CVARS.Bools["Player Info"] = CreateClientConVar( BH.RandomPrefix.."_perp_playerinfo", "1", true, true );
BH.CVARS.Bools["Trigger bot"] = CreateClientConVar( BH.RandomPrefix.."_triggerbot", "1", true, true );
BH.CVARS.Bools["Trigger bot on scan"] = CreateClientConVar( BH.RandomPrefix.."_triggerbota", "1", true, true );
BH.CVARS.Bools["Trigger bot team mates"] = CreateClientConVar( BH.RandomPrefix.."_triggerbot_friendly_fire", "1", true, true );
BH.CVARS.Bools["Trigger bot steam friends"] = CreateClientConVar( BH.RandomPrefix.."_triggerbot_steam_friends", "1", true, true );
BH.CVARS.Bools["Auto pistol"] = CreateClientConVar( BH.RandomPrefix.."_auto_pistol", "1", true, true );
BH.CVARS.Bools["ESP: Bounding Box"] = CreateClientConVar( BH.RandomPrefix.."_esp_2dbox", "1", true, true );
BH.CVARS.Bools["ESP: TTT Show traitors"] = CreateClientConVar( BH.RandomPrefix.."_esp_show_traitors", "1", true, true );
BH.CVARS.Bools["ESP: TTT Show dead bodies"] = CreateClientConVar( BH.RandomPrefix.."_esp_show_dead_bodies", "1", true, true );
BH.CVARS.Bools["ESP: TTT Show C4"] = CreateClientConVar( BH.RandomPrefix.."_esp_show_c4", "1", true, true );
BH.CVARS.Numbers["Spe1edha1ck"] = CreateClientConVar( BH.RandomPrefix.."_spe1ed", "5", true, true );
BH.CVARS.Bools["Show Admins Connect"] = CreateClientConVar( BH.RandomPrefix.."_show_admins", "1", true, true );
BH.CVARS.Bools["Chams"] = CreateClientConVar( BH.RandomPrefix.."_chams_enabled", "1", true, true );
BH.CVARS.Bools["Crosshair"] = CreateClientConVar( BH.RandomPrefix.."_crosshair_enabled", "1", true, true );
BH.CVARS.Bools["No Recoil"] = CreateClientConVar( BH.RandomPrefix.."_no_recoil", "1", true, true );
BH.CVARS.Bools["No Visual Recoil"] = CreateClientConVar( BH.RandomPrefix.."_no_visual_recoil", "1", true, true );
BH.CVARS.Bools["Traitor Detector"] = CreateClientConVar( BH.RandomPrefix.."_traitor_detector", "1", true, true );
BH.CVARS.Bools["Show Spectators"] = CreateClientConVar( BH.RandomPrefix.."_show_spectators", "1", true, true );
BH.CVARS.Bools["Bunny hop"] = CreateClientConVar( BH.RandomPrefix.."_bunnyhop", "1", true, true );
BH.Mat = CreateMaterial( string.lower( BH.RandomString( math.random( 5, 8 ), false, false ) ), "VertexLitGeneric", { ["$basetexture"] = "models/debug/debugwhite", ["$model"] = 1, ["$ignorez"] = 1 } );
BH.HeadPos = nil;
BH.JumpReleased = false;
BH.TraceRes = nil;
BH.Font = nil;
BH.IsTraitor = nil;
BH.IsTTT = false;
BH.IsPERP = false;
BH.IszMOD = false;
BH.IsGmodZ = false;
BH.PrintEx = MsgC;
BH.LatestVersion = nil;
BH.Version = "3.0";
BH.V = 80;
BH.TimerName = BH.RandomString( 0, false, false );
BH.Unloaded = false;
BH.ToggleFade = nil;


function BH.Init( )
	--Eww this is ugly
	BH.Font = BH.RandomString( 0, false, false );
	surface.CreateFont( BH.Font, { font = "DefaultFixedDropShadow", size = 14, weight = 750, antialias = false, outline = true } );
	BH.IsTTT = string.find( GAMEMODE.Name , "Terror" );
	BH.IsPERP = string.find( GAMEMODE.Name , "PERP" );
	BH.IszMOD = string.find( GAMEMODE.Name , "Z_mod" );
	BH.IsGmodZ = ( string.lower( GAMEMODE.Name ) == "gmodz" );
	
	RunConsoleCommand( "showconsole" );
	Msg( "\n\n\n" );
	BH.Print( true, true, Color( 25, 225, 80 ), "Loaded!", Color( 255, 255, 255 ), "\tv"..BH.Version );
	BH.Print( true, true, Color( 255, 255, 255 ), "Your prefix is "..BH.RandomPrefix );
	BH.Print( true, true, Color( 255, 255, 255 ), "Checking for updates..." );
	
	http.Fetch( "http://bluehawk.googlecode.com/svn/trunk/%20bluehawk/hawk.lua", 
		function( HTML ) 
			local findpos = string.find( HTML, "BHVERSION=", 0, false );
			
			if (findpos) then
				local version = tonumber( string.sub( HTML, findpos+10, findpos+13 ) );
				if ( version > BH.V ) then
					BH.Print( true, true, Color( 255, 200, 200 ), "Your version is out of date!" );
					BH.LatestVersion = HTML;
					BH.UpdateMenu();
				else
					BH.Print( true, true, Color( 200, 255, 200 ), "Your version is up to date." );
				end
			end
		end,
		
		function() 
			BH.Error( "Failed checking for updates." );
		end
	);
	
	if (BH.IsTTT) then
		BH.IsTraitor = BH.MetaPlayer.IsTraitor
		
		function BH.MetaPlayer:IsTraitor()
			if (self == BH.ply()) then return BH.IsTraitor( self ); end
			
			if (!table.HasValue( BH.Traitors, self ) || !BH.CVARS.Bools["Traitor Detector"].cvar:GetBool()) then
				return BH.IsTraitor( self );
			else
				return true;
			end
		end
	end
end

function BH.Print( timestamp, stamp, ... )
	if (timestamp) then
		Msg( "["..os.date("%H:%M:%S").."] " );
	end
	
	if (stamp) then
		MsgC( Color( 0, 150, 255 ), "[Blue Hawk] " );
	end
	
	local t = {...};
	
	if (#t == 1) then
		BH.PrintEx( Color(255, 255, 255), t[1] );
	else
		for i = 1, #t, 2 do
			BH.PrintEx( t[i], t[i+1] );
		end
	end
	
	Msg('\n');
end


local weed = Material( "vgui/Benjamin/weed.png", nocull );
local shield = Material( "icon16/shield.png", nocull );
local shieldadd = Material( "icon16/shield_add.png", nocull );
local user = Material( "icon16/user.png", nocull );
local heart = Material( "icon16/heart.png", nocull );
local money = Material( "icon16/money.png", nocull );
local items = Material( "vgui/Benjamin/item.png", nocull );
local coke = Material( "vgui/Benjamin/coke.png", nocull );
local gun = Material( "vgui/Benjamin/gun.png", nocull );
local can = Material( "vgui/Benjamin/can.png", nocull );
local food = Material( "vgui/Benjamin/food.png", nocull );


hook.Add("HUDPaint", "PERPY", function()

	if GetConVarNumber("hawk_dd") == 1 and ( gmod.GetGamemode().Name ) == "PERP" or ( gmod.GetGamemode().Name ) == "RealityRoleplay" then
	local buying = GetGlobalInt("perp_druggy_buy", 0 )
	local selling = GetGlobalInt("perp_druggy_sell", 0 )	
	local cantroBHank = GetGlobalBool("perp_bank_roBHing_timer")
	local moneyinbank = GetGlobalInt("perp_realtor_money")	
			local posx = 17
		local posy = 15
		draw.RoundedBox( 2, ScrW() / 11 -125, 170, 100, 80, Color(45,45,45,180) )
		draw.RoundedBox( 2, ScrW() / 11 -125, 155, 100, 20, lblue )
		draw.SimpleText("Dealer", "Trebuchet18", ScrW() /11 - 75, 160, white, TEXT_ALIGN_CENTER )
			local buyingtbl = {
				"Buying Weed",
				"Buying Meth",
				"Buying Shrooms",
				"Buying LSD",
				"Buying Cocaine",
				"Buying Muscle"
			}
			buyingtbl[0] = "Not Buying"
			draw.SimpleText( buyingtbl[buying], "Trebuchet18", ScrW() /11 - 75, posy + 185, white, TEXT_ALIGN_CENTER, TEXT_ALIGN_TOP )
			local sellingtbl = {
				"Selling Seeds",
				"Selling LSD",
				"Selling Muscle",
				"Selling Shrooms",
				"Selling Cocaine",
			}
			sellingtbl[0] = "Not Selling"
			draw.SimpleText( sellingtbl[selling], "Trebuchet18", ScrW() /11 - 75, posy + 215, white, TEXT_ALIGN_CENTER, TEXT_ALIGN_TOP)
	end
end)

function PlayerInfo()
HP = LocalPlayer():Health()
AR = LocalPlayer():Armor()
if GetConVarNumber("hawk_perp_playerinfo") == 1 then
if ( gmod.GetGamemode().Name ) == "PERP" or ( gmod.GetGamemode().Name ) == "RealityRoleplay" then
draw.RoundedBox(0, ScrW() / 2.65 / 2 - 325, 43, 125, 105, Color(45,45,45,180))
draw.RoundedBox(0, ScrW() / 2.65 / 2 -325, 43, 125, 20, lblue )
draw.SimpleText("Player Info", "Trebuchet18", ScrW() /2.65 / 2 -265, 47, white, TEXT_ALIGN_CENTER )

--HP Bar
draw.RoundedBox(0, ScrW() / 2.65 / 2 - 296, 68, 82, 10, Color(0,0,0,255))
draw.RoundedBox(0, ScrW() / 2.65 / 2 - 295, 69, 80 * math.Clamp(HP, 0, 100) / 100, 8, Color(255,0,0,255))
draw.RoundedBox(0, ScrW() / 2.65 / 2 - 295, 69, 80 * math.Clamp(HP, 0, 100) / 100, 4, Color(255,255,255,30))
draw.DrawText(HP .. "%", "Trebuchet18", ScrW() / 2 / 2.65 -256, 67, Color(255, 255, 255, 255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
surface.SetMaterial( heart ); surface.SetDrawColor( Color( 255, 255, 255, 255 ) ); surface.DrawTexturedRect( ScrW() /2.65 / 2 -318, 65, 16, 16 );

--Armor Bar
draw.RoundedBox(0, ScrW() / 2.65 / 2 - 296, 88, 82, 10, Color(0,0,0,255))
draw.RoundedBox(0, ScrW() / 2.65 / 2 - 295, 89, 80 * math.Clamp(AR, 0, 100) / 100, 8, Color(0,0,255,255))
draw.RoundedBox(0, ScrW() / 2.65 / 2 - 295, 89, 80 * math.Clamp(AR, 0, 100) / 100, 4, Color(255,255,255,30))
draw.DrawText(AR .. "%", "Trebuchet18", ScrW() / 2.65 / 2 -256, 87, Color(255, 255, 255, 255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
surface.SetMaterial( shield ); surface.SetDrawColor( Color( 255, 255, 255, 255 ) ); surface.DrawTexturedRect( ScrW() /2.65 / 2 -318, 85, 16, 16 );

--Name
surface.SetMaterial( user ); surface.SetDrawColor( Color( 255, 255, 255, 255 ) ); surface.DrawTexturedRect( ScrW() /2.65 / 2 -318, 105, 16, 16 );
draw.DrawText(LocalPlayer():GetRPName(), "Trebuchet18", ScrW() / 2.65 / 2 -256, 108, Color(255, 255, 255, 255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)


--Money in bank
surface.SetMaterial( money ); surface.SetDrawColor( Color( 255, 255, 255, 255 ) ); surface.DrawTexturedRect( ScrW() /2.65 / 2 -318, 125, 16, 16 );
draw.DrawText("$".. string.Comma(LocalPlayer():GetBank()), "Trebuchet18", ScrW() / 2.65 / 2 -256, 128, Color(255, 255, 255, 255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)


end
end
end
hook.Add("HUDPaint", "PlayerInfo", PlayerInfo)



function BH.PrintChat( ... )
	chat.AddText( Color( 50, 100, 255 ), "[Blue Hawk] ", ... );
end

function BH.Error( error )
	Msg( "["..os.date("%H:%M:%S").."] " );
	MsgC( Color( 255, 50, 50 ), "[Blue Hawk] ERROR: " );
	MsgC( Color( 255, 255, 255 ), error.."\n" );
end

function BH.IsOnTeam( ply )
	if ( BH.IsTTT ) then
		return ply:IsTraitor() == BH.ply():IsTraitor();
	else
		return ply:Team() == BH.ply():Team();
	end
end

function BH.GetValidPlayers( )
	local players = { };
	
	for _, ply in pairs( BH.players() ) do
		if ( ply != BH.ply && IsValid( ply ) && 
		ply:IsPlayer() && 
		ply:Alive() && 
		ply:Health() >= 1 &&
		( ply:GetFriendStatus() != "friend" || BH.CVARS.Bools["Aim at steam friends"].cvar:GetBool() ) &&
		( !BH.IsOnTeam( ply ) || BH.CVARS.Bools["Aim at team mates"].cvar:GetBool() ) ) then
			table.insert( players, ply );
		end
	end
	
	return players
end

function BH:IsAdmin( e )
	if e:IsAdmin() or e:IsSuperAdmin() then return true end
	return false
end

function BH:IsFriend( e )
	if ( e:GetFriendStatus() == "friend" ) then return true end
	return false
end

function BH.IsVisible( ply )
	if (!IsValid( ply )) then return false end;
	if (ply == LocalPlayer()) then return false end;
	if ( ( ply:IsAdmin() or ply:IsSuperAdmin()) && BH.CVARS.Bools["Ignore admins"].cvar:GetBool() ) then return false end;
	if (BH.CVARS.Bools["Ignore LOS"].cvar:GetBool()) then return true end;
	
	local vecPos, _ = ply:GetBonePosition( ply:LookupBone( "ValveBiped.Bip01_Head1" ) or 12 );
	local trace = { start = BH.ply():EyePos(), endpos = vecPos, filter = BH.ply(), mask = MASK_SHOT };
	local traceRes = util.TraceLine( trace );
	
	BH.TraceRes = traceRes;
		
	if (traceRes.HitWorld || traceRes.Entity != ply) then return false end;
	
	return true;
end

function BH.IsCloseAim( ent )
	local dist = ent:GetPos():Distance( LocalPlayer():GetPos() )
	if( dist <= BH.CVARS.Numbers["Aim Distance"].cvar:GetFloat() and ent:GetPos() != Vector( 0, 0, 0 ) ) then
		return true
	end
	return false	
end

function BH.IsCloseEnough( ent )
	local dist = ent:GetPos():Distance( LocalPlayer():GetPos() )
	if( dist <= BH.CVARS.Numbers["ESP: Distance"].cvar:GetFloat() and ent:GetPos() != Vector( 0, 0, 0 ) ) then
		return true
	end
	return false	
end




local function GetAdminType(e)
	if e:IsAdmin() && !e:IsSuperAdmin() then
		return " [A] "
	elseif( e:IsSuperAdmin() ) then
		return " [SA] "
	end
	return " "
end


function BH.ClosestAngle( players )
	BH.RandomAimSpot = "ValveBiped.Bip01_Spine2";
	BH.StaticAimSpot = "ValveBiped.Bip01_Head1";
	local flAngleDifference = nil;
	local newAngle = nil;
	local viewAngles = BH.ply():EyeAngles();
	
	for _, ply in pairs( players ) do
			if (BH.CVARS.Bools["Random Aimspot"].cvar:GetBool() == true) then
		targetspot = BH.RandomAimSpot;
		else
		targetspot = BH.StaticAimSpot;
		end
		local vecPos, ang = ply:GetBonePosition( ply:LookupBone( targetspot ) or 12 );
		local oldpos = vecPos;
		vecPos = vecPos - BH.VelocityPrediction( BH.ply() ) + BH.VelocityPrediction( ply )
		local angAngle = ( vecPos - BH.ply():EyePos() ):Angle()
		local flDif = math.abs( math.AngleDifference( angAngle.p, viewAngles.p ) ) + math.abs( math.AngleDifference( angAngle.y, viewAngles.y ) );
		
		if ((flAngleDifference == nil || flDif < flAngleDifference) && (!BH.CVARS.Numbers["Max Angle"].cvar:GetBool() || flDif < BH.CVARS.Numbers["Max Angle"].cvar:GetFloat()) && BH.IsCloseAim(ply)) then
			BH.HeadPos = oldpos:ToScreen();
			BH.Target = ply;
			flAngleDifference = flDif;
			newAngle = angAngle;
		end
	end
	
	return newAngle;
end

function BH.VelocityPrediction( ply ) return ply:GetAbsVelocity() * 0.013; end

function BH.Aimbot( )
	BH.HeadPos = nil;
	BH.Aimbotting = false;
	
	if (!BH.CVARS.Bools["Aimbot"].cvar:GetBool() || !BH.mouse1 && (BH.CVARS.Bools["Aim on key"].cvar:GetBool() == true || BH.CVARS.Bools["Aim on mouse1"].cvar:GetBool() == true) && !BH.AimbotKeyDown) then return end
	
	local players = {};
	
	for _, ply in pairs( BH.GetValidPlayers() ) do
		if (BH.IsVisible( ply )) then
			table.insert( players, ply );
		end
	end
	
	if (table.Count( players ) == 0) then 
		BH.Target = nil;
		return
	end;
	
	local newAngle = BH.ClosestAngle( players );
	
	if ( newAngle != nil ) then 
		BH.ply():SetEyeAngles( newAngle );
		BH.Aimbotting = true;
	end
end

function BH.TableSortByDistance( former, latter ) return latter:GetPos():Distance( BH.ply():GetPos() ) > former:GetPos():Distance( BH.ply():GetPos() ) end
function BH.TableSortByAsc( former, latter ) print( "hey" ) return string.byte( string.lower( former.name ), 1 ) < string.byte( string.lower( latter.name ), 1 ) end

function BH.GetPlayersByDistance( )
	local players = BH.players( );
	
	table.sort( players, BH.TableSortByDistance );
	
	return players;
end

function BH.CreateMove( cmd )
	if (BH.IsTTT && BH.ply():Alive() && BH.ply():Health() >= 1 && BH.ply():Team() != TEAM_SPECTATOR) then
		BH.ply().voice_battery = 100; --Infinite voichat time I don't need to check if it's TTT because swag
	end
	
	if (cmd:KeyDown( IN_ATTACK ) && !BH.mouse1 && BH.CVARS.Bools["Aim on mouse1"].cvar:GetBool() == true ) then
		BH.mouse1 = true;
		BH.Aimbot( );
	elseif ( !cmd:KeyDown( IN_ATTACK ) && BH.mouse1 && BH.CVARS.Bools["Aim on mouse1"].cvar:GetBool() == true ) then
		BH.mouse1 = false;
	end
	
	if (BH.CVARS.Bools["No Recoil"].cvar:GetBool() && IsValid( BH.ply() ) && BH.ply():Alive() && BH.ply():Health() > 0 && IsValid( BH.ply():GetActiveWeapon() )) then
		if ( BH.ply():GetActiveWeapon().Primary && BH.ply():GetActiveWeapon().Primary.Recoil ) then
			BH.Recoils[BH.ply():GetActiveWeapon():EntIndex()] = BH.ply():GetActiveWeapon().Primary.Recoil;
			BH.ply():GetActiveWeapon().Primary.Recoil = 0;
		end
	end
---------------------------------------trigger 1-----------------------------------	
	local triggerbot = false;
	
	if (BH.CVARS.Bools["Trigger bot"].cvar:GetBool()) && BH.Aimbotting  && BH.AimbotKeyDown then
		local trace = BH.ply():GetEyeTrace();
		
		if (IsValid( trace.Entity ) && trace.Entity:IsPlayer() && BH.Aimbotting  && BH.AimbotKeyDown && (trace.Entity:Team() != BH.ply():Team() || BH.CVARS.Bools["Trigger bot team mates"].cvar:GetBool()) && (trace.Entity:GetFriendStatus() != "friend" || BH.CVARS.Bools["Trigger bot steam friends"].cvar:GetBool())) then
			triggerbot = true;
		end
	end
	
	if (!cmd:KeyDown( IN_ATTACK ) && (BH.CVARS.Bools["Trigger bot"].cvar:GetBool() && BH.Aimbotting   && BH.AimbotKeyDown|| triggerbot)) then
		cmd:SetButtons( IN_ATTACK + cmd:GetButtons() );
	end
	
	---------------------------------------trigger 2-----------------------------------	
	--//JUST 4 U JENNY
	
		local triggerbot = false;
	
	if (BH.CVARS.Bools["Trigger bot on scan"].cvar:GetBool()) && BH.AimbotKeyDown then
		local trace = BH.ply():GetEyeTrace();
		
		if (IsValid( trace.Entity ) && trace.Entity:IsPlayer()  && BH.AimbotKeyDown && (trace.Entity:Team() != BH.ply():Team() || BH.CVARS.Bools["Trigger bot team mates"].cvar:GetBool()) && (trace.Entity:GetFriendStatus() != "friend" || BH.CVARS.Bools["Trigger bot steam friends"].cvar:GetBool())) then
			triggerbot = true;
		end
	end
	
	if (!cmd:KeyDown( IN_ATTACK ) && (BH.CVARS.Bools["Trigger bot on scan"].cvar:GetBool() && BH.AimbotKeyDown|| triggerbot)) then
		cmd:SetButtons( IN_ATTACK + cmd:GetButtons() );
	end
	
	-------------------------------------------------------------------------------------
	
	if (cmd:KeyDown( IN_ATTACK ) && BH.CVARS.Bools["Auto pistol"].cvar:GetBool() && IsValid( BH.ply():GetActiveWeapon() ) && BH.ply():GetActiveWeapon():GetClass() != "weapon_ar2" && BH.ply():GetActiveWeapon():GetClass() != "weapon_smg1" && (!BH.ply():GetActiveWeapon().Primary or BH.ply():GetActiveWeapon().Primary.Automatic == false)) then
		if (BH.ShouldFire == 3) then
			cmd:RemoveKey( IN_ATTACK );
			BH.ShouldFire = 0;
		end
		
		BH.ShouldFire = BH.ShouldFire + 1;
	else
		BH.ShouldFire = 0;
	end
	
	if (cmd:KeyDown( IN_JUMP )) then --Credits to gir489 original code for TF2
		if (!BH.JumpReleased) then
			if (BH.CVARS.Bools["Bunny hop"].cvar:GetBool() && !BH.ply():OnGround()) then
				cmd:RemoveKey( IN_JUMP );
			end
		else
			BH.JumpReleased = false
		end
	elseif (!BH.JumpReleased) then
		BH.JumpReleased = true;
	end
end

function BH.NoVisualRecoil( ply, pos, angles, fov )
   if (BH.CVARS.Bools["No Visual Recoil"].cvar:GetBool() && BH.ply():Health() > 0 && BH.ply():Team() != TEAM_SPECTATOR && BH.ply():Alive()) then
	   return GAMEMODE:CalcView( ply, BH.ply():EyePos(), BH.ply():EyeAngles(), fov, 0.1 );
   end
end

function BH.AddToColor( color, add )
	return color + add <= 255 and color + add or color + add - 255
end

function BH.SubtractFromColor( color, sub )
	return color - sub >= 0 and color - sub or color - sub + 255
end

function BH.IsPerpWeed( entclass )
	return table.HasValue( BH.PerpWeed, entclass )
end

function BH.IsPerpCocaine( entclass )
	return table.HasValue( BH.PerpCocaine, entclass )
end

function BH.IszModWeapon( entclass )
	return table.HasValue( BH.zModWeapons, entclass )
end

function BH.IszModCan( entclass )
	return table.HasValue( BH.zMod, entclass )
end

function BH.IsGmodZFood( entclass )
	return table.HasValue( BH.GmodZFood, entclass )
end

function BH.IsGmodZItem( entclass )
	return table.HasValue( BH.GmodZItem, entclass )
end

function BH.IsPerpItems( entclass )
	return table.HasValue( BH.PerpItems, entclass )
end

function BH.ESP( ) 
	if (!BH.CVARS.Bools["Crosshair"].cvar:GetBool() && !BH.CVARS.Bools["ESP"].cvar:GetBool()) then return end;
	
	if ( BH.CVARS.Bools["Crosshair"].cvar:GetBool() ) then
		surface.SetDrawColor( Color( 255, 255, 255 ) );
		surface.DrawLine( ScrW()/2-10, ScrH()/2, ScrW()/2-4, ScrH()/2 );
		surface.DrawLine( ScrW()/2+10, ScrH()/2, ScrW()/2+4, ScrH()/2 );
		surface.DrawLine( ScrW()/2, ScrH()/2-10, ScrW()/2, ScrH()/2-4 );
		surface.DrawLine( ScrW()/2, ScrH()/2+10, ScrW()/2, ScrH()/2+4 );
	end

	if ( !BH.CVARS.Bools["ESP"].cvar:GetBool() ) then return end
	
	surface.SetFont( BH.Font );
	draw.SimpleText(" [Blue Hawk] "..BH.Version, BH.Font, 50, 10, Color( 50, 100, 255 )); --watermark just so i know im cool
	
	for _, ply in pairs( BH.players() ) do
		if (ply != BH.ply() && ply:Health() >= 1 && ply:Alive() && ply:Team() != TEAM_SPECTATOR) then
			local min, max = ply:GetRenderBounds();
			local pos = ply:GetPos() + Vector( 0, 0, ( min.z + max.z ) );
			local color = Color( 50, 255, 50, 255 );
			
			if ( ply:Health() <= 10 ) then color = Color( 255, 0, 0, 255 );
			elseif ( ply:Health() <= 20 ) then color = Color( 255, 50, 50, 255 );
			elseif ( ply:Health() <= 40 ) then color = Color( 250, 250, 50, 255 );
			elseif ( ply:Health() <= 60 ) then color = Color( 150, 250, 50, 255 ); 
			elseif ( ply:Health() <= 80 ) then color = Color( 100, 255, 50, 255 ); end
			
			pos = ply:GetPos():ToScreen();
			
			if ( BH.CVARS.Bools["ESP: Show name"].cvar:GetBool() && BH.IsCloseEnough(ply) ) then
				local width, height = surface.GetTextSize( tostring( ply:Nick() ) ); -- I have to do tostring because sometimes errors would occur
				draw.DrawText( ply:Nick()..GetAdminType(ply), BH.Font, pos.x, pos.y, ( BH.IsTTT && ply:IsTraitor() || ply:IsAdmin() or ply:IsSuperAdmin() ) and Color( 255, 150, 150, 255 ) or Color( 255, 255, 255, 255 ), 1 );
				pos.y = pos.y + 16;
			end

			if ( BH.IsTTT && BH.CVARS.Bools["ESP: TTT Show traitors"].cvar:GetBool() && ply:IsTraitor() && BH.IsCloseEnough(ply)  ) then
				local width, height = surface.GetTextSize( "TRAITOR" );
				draw.DrawText( "TRAITOR", BH.Font, pos.x, pos.y, Color( 255, 0, 0, 255 ), 1 );
				pos.y = pos.y + 20;
			end
			
			if (BH.CVARS.Bools["ESP: Show health"].cvar:GetBool() && BH.IsCloseEnough(ply) ) then
				local width, height = surface.GetTextSize( "Health: "..tostring( ply:Health() ) );
				draw.DrawText( "Health: "..tostring( ply:Health() ), BH.Font, pos.x, pos.y, color, 1 );
				pos.y = pos.y + 13;
			end
			
			if (BH.CVARS.Bools["ESP: Show weapon"].cvar:GetBool() && IsValid( ply:GetActiveWeapon() ) && BH.IsCloseEnough(ply) ) then
				local width, height = surface.GetTextSize( ply:GetActiveWeapon():GetPrintName() or ply:GetActiveWeapon():GetClass() );
				draw.DrawText( ply:GetActiveWeapon():GetPrintName() or ply:GetActiveWeapon():GetClass(), BH.Font, pos.x, pos.y, Color( 255, 200, 50 ), 1 );
			end
			
			if (BH.CVARS.Bools["ESP: Show Skeleton"].cvar:GetBool() && BH.IsCloseEnough(ply)) then
				for k, v in pairs( BH.espbones ) do
					local sPos, ePos = ply:GetBonePosition( ply:LookupBone( v.S ) ):ToScreen(), ply:GetBonePosition( ply:LookupBone( v.E ) ):ToScreen(); --causes errors on ttt round changes
					if ply:IsPlayer() or ply:IsNPC() then
						surface.SetDrawColor(( BH.IsTTT && ply:IsTraitor() || ply:IsAdmin() or ply:IsSuperAdmin() ) and Color( 200, 50, 50, 255 ) or team.GetColor(ply:Team()));
					end
					surface.DrawLine(sPos.x,sPos.y,ePos.x,ePos.y)
					end
			end
		end
	end
	
	if (BH.IsTTT) then
		if (BH.CVARS.Bools["ESP: TTT Show C4"].cvar:GetBool()) then
			for _, ent in pairs( ents.FindByClass( "ttt_c4" ) ) do
				if (!BH.ply():IsTraitor() or !ent:GetArmed()) then
					local pos = ent:GetPos():ToScreen();
					local width, height = surface.GetTextSize( "C4" );
					
					draw.DrawText( !ent:GetArmed() and "C4 - Unarmed" or "C4 - "..string.FormattedTime(ent:GetExplodeTime() - CurTime(), "%02i:%02i"), BH.Font, pos.x, pos.y-height/2, Color( 255, 200, 200, 255 ), 1 );
				end
			end
		end
		
		if (BH.CVARS.Bools["ESP: TTT Show dead bodies"].cvar:GetBool() ) then
			for _, ent in pairs( ents.FindByClass( "prop_ragdoll" ) ) do
				local name = CORPSE.GetPlayerNick( ent, false );
				
				if ( name != false ) && BH.IsCloseEnough(ent) then
					local pos = ent:GetPos():ToScreen();
					local width, height = surface.GetTextSize( name );
					
					draw.DrawText( name, BH.Font, pos.x, pos.y-height/2, Color( 255, 255, 255, 255 ), 1 );
					
					if ( !CORPSE.GetFound(ent, false) ) then
						draw.DrawText( "Unidentified", BH.Font, pos.x, pos.y-height/2+12, Color( 200, 200, 0, 255 ), 1 );
					end
				end
			end
		end
	end
	
	if (BH.IsPERP) then
        for _, ent in pairs(ents.GetAll()) do
            if BH.IsPerpWeed( ent:GetClass() ) && BH.IsCloseEnough(ent) then
				local rpepos = ent:GetPos()
                  if rpepos:ToScreen().x > 0 and
                     rpepos:ToScreen().y > 0 and
                     rpepos:ToScreen().x < ScrW() and
                     rpepos:ToScreen().y < ScrH() then
                        local rppos1 = (ent:LocalToWorld( Vector(0,0,0)) ):ToScreen()
							surface.SetMaterial( weed ); surface.SetDrawColor( Color( 255, 255, 255, 255 ) ); surface.DrawTexturedRect( rppos1.x - 5, rppos1.y - 20, 16, 16 );
							draw.SimpleText( "Weed", "Trebuchet18", rppos1.x, rppos1.y, Color( 0, 255, 0, 255 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
                   end
            end
        end
	end
	
		if (BH.IsPERP) then
        for _, ent in pairs(ents.GetAll()) do
            if BH.IsPerpItems( ent:GetClass() ) && BH.IsCloseEnough(ent) then
				local rpepos = ent:GetPos()
                  if rpepos:ToScreen().x > 0 and
                     rpepos:ToScreen().y > 0 and
                     rpepos:ToScreen().x < ScrW() and
                     rpepos:ToScreen().y < ScrH() then
                        local rppos1 = (ent:LocalToWorld( Vector(0,0,0)) ):ToScreen()
							surface.SetMaterial( items ); surface.SetDrawColor( Color( 255, 255, 255, 255 ) ); surface.DrawTexturedRect( rppos1.x - 5, rppos1.y - 20, 16, 16 );
							draw.SimpleText( "Item", "Trebuchet18", rppos1.x, rppos1.y, Color( 0, 100, 100, 100 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
                   end
            end
        end
	end
	
			if (BH.IsPERP) then
        for _, ent in pairs(ents.GetAll()) do
            if BH.IsPerpCocaine( ent:GetClass() ) && BH.IsCloseEnough(ent) then
				local rpepos = ent:GetPos()
                  if rpepos:ToScreen().x > 0 and
                     rpepos:ToScreen().y > 0 and
                     rpepos:ToScreen().x < ScrW() and
                     rpepos:ToScreen().y < ScrH() then
                        local rppos1 = (ent:LocalToWorld( Vector(0,0,0)) ):ToScreen()
							surface.SetMaterial( coke ); surface.SetDrawColor( Color( 255, 255, 255, 255 ) ); surface.DrawTexturedRect( rppos1.x - 5, rppos1.y - 20, 16, 16 );
							draw.SimpleText( "Coke", "Trebuchet18", rppos1.x, rppos1.y, Color( 255, 0, 0, 255 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
                   end
            end
        end
	end
	
				if (BH.IszMOD) then
        for _, ent in pairs(ents.GetAll()) do
            if BH.IszModCan( ent:GetClass() ) && BH.IsCloseEnough(ent) then
				local rpepos = ent:GetPos()
                  if rpepos:ToScreen().x > 0 and
                     rpepos:ToScreen().y > 0 and
                     rpepos:ToScreen().x < ScrW() and
                     rpepos:ToScreen().y < ScrH() then
                        local rppos1 = (ent:LocalToWorld( Vector(0,0,0)) ):ToScreen()
							surface.SetMaterial( can ); surface.SetDrawColor( Color( 255, 255, 255, 255 ) ); surface.DrawTexturedRect( rppos1.x - 5, rppos1.y - 20, 16, 16 );
							draw.SimpleText( "Opener", "Trebuchet18", rppos1.x, rppos1.y, Color( 255, 0, 0, 255 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
                   end
            end
        end
	end
	
					if (BH.IszMOD) then
        for _, ent in pairs(ents.GetAll()) do
            if BH.IszModWeapon( ent:GetClass() ) && BH.IsCloseEnough(ent) then
				local rpepos = ent:GetPos()
                  if rpepos:ToScreen().x > 0 and
                     rpepos:ToScreen().y > 0 and
                     rpepos:ToScreen().x < ScrW() and
                     rpepos:ToScreen().y < ScrH() then
                        local rppos1 = (ent:LocalToWorld( Vector(0,0,0)) ):ToScreen()
							surface.SetMaterial( gun ); surface.SetDrawColor( Color( 255, 255, 255, 255 ) ); surface.DrawTexturedRect( rppos1.x - 5, rppos1.y - 20, 16, 16 );
							draw.SimpleText( "Gun", "Trebuchet18", rppos1.x, rppos1.y, Color( 255, 0, 0, 255 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
                   end
            end
        end
	end
	
	
					if (BH.IsGmodZ) then
        for _, ent in pairs(ents.GetAll()) do
            if BH.IsGmodZFood( ent:GetClass() ) && BH.IsCloseEnough(ent) then
				local rpepos = ent:GetPos()
                  if rpepos:ToScreen().x > 0 and
                     rpepos:ToScreen().y > 0 and
                     rpepos:ToScreen().x < ScrW() and
                     rpepos:ToScreen().y < ScrH() then
                        local rppos1 = (ent:LocalToWorld( Vector(0,0,0)) ):ToScreen()
							surface.SetMaterial( food ); surface.SetDrawColor( Color( 255, 255, 255, 255 ) ); surface.DrawTexturedRect( rppos1.x - 5, rppos1.y - 20, 16, 16 );
							draw.SimpleText( "Food", "Trebuchet18", rppos1.x, rppos1.y, Color( 255, 165, 0, 255 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
                   end
            end
        end
	end
	
						if (BH.IsGmodZ) then
        for _, ent in pairs(ents.GetAll()) do
            if BH.IsGmodZItem( ent:GetClass() ) && BH.IsCloseEnough(ent) then
				local rpepos = ent:GetPos()
                  if rpepos:ToScreen().x > 0 and
                     rpepos:ToScreen().y > 0 and
                     rpepos:ToScreen().x < ScrW() and
                     rpepos:ToScreen().y < ScrH() then
                        local rppos1 = (ent:LocalToWorld( Vector(0,0,0)) ):ToScreen()
							surface.SetMaterial( items ); surface.SetDrawColor( Color( 255, 255, 255, 255 ) ); surface.DrawTexturedRect( rppos1.x - 5, rppos1.y - 20, 16, 16 );
							draw.SimpleText( "Item", "Trebuchet18", rppos1.x, rppos1.y, Color( 255, 10, 150, 255 ), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
                   end
            end
        end
	end
	
	
	if (BH.HeadPos != nil) then  --draw scanning and locked
		local width = 5;
		local height = 5;
		surface.SetDrawColor( Color( 255, 0, 0, 255 ) );
		surface.DrawOutlinedRect( BH.HeadPos.x-width/2, BH.HeadPos.y-height/2, width, height );
		draw.DrawText( "Locked", BH.Font, ScrW()/2, ScrH()/2 + 15, Color( 255, 0, 0, 200 ), 1 );
		else
		draw.DrawText( (BH.AimbotKeyDown and "Scanning" or " "), BH.Font, ScrW()/2, ScrH()/2 + 15, Color( 255, 0, 0, 200 ), 1 );
	end
	
	if(BH.CVARS.Bools["ESP: Show Adminlist"].cvar:GetBool()) then --credits:sethhackv2
        local admins = {}
        local int = 0
                for k, v in ipairs( player.GetAll() ) do
                        if( v:IsAdmin() && v:IsSuperAdmin() ) then
                                table.insert( admins, v:Nick() .. " [SA]" )
                        elseif( v:IsAdmin() && !v:IsSuperAdmin() ) then
                                table.insert( admins, v:Nick() .. " [A]" )
                        end
                end
                local txtsize = surface.GetTextSize( table.concat( admins ) ) / 3
                draw.SimpleText("Admins", BH.Font, ScrW() - 155, ScrH() - ScrH() + 16, Color( 255, 255, 255, 255 ) )
                for k, v in pairs( admins ) do
                        draw.SimpleText(v, BH.Font, ScrW() - 195, ScrH() - ScrH() + 35 + int, Color( 255, 255, 255, 255 ) )
                        int = int + 15
                end
    end
	
	if (BH.CVARS.Bools["ESP: Show Weapons"].cvar:GetBool()) then
		for k, v in pairs( ents.GetAll() ) do
			if IsValid( v ) then
				if v:IsWeapon() && v:GetMoveType() != 0 && BH.IsCloseEnough(v) then
					if string.sub( v:GetClass(), 1, 7 ) == "weapon_" then
						WeaponPos = v:EyePos():ToScreen()
						draw.SimpleText( v:GetClass(), BH.Font, WeaponPos.x, WeaponPos.y, Color(0, 200, 0, 200), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER )
					end
				end
			end
		end
	end

	if (BH.CVARS.Bools["ESP: Bounding Box"].cvar:GetBool()) then
		cam.Start3D(EyePos(), EyeAngles());
			for k, ply in pairs(player.GetAll()) do
				if( ply:Alive() && ( IsValid(ply) && ply != LocalPlayer() ) && BH.IsCloseEnough(ply) ) then --i like seeing spec boxs for ttt so i keep specs
					local pos = ply:GetPos();
					local width = 32;
					local height = 80;
					local scale = 1;
					local BoxColor = ( BH.IsTTT && ply:IsTraitor() ) and Color( 200, 50, 50, 255 ) or team.GetColor(ply:Team());
					local ang = EyeAngles();
					ang.p = ang.p - 90;
					pos = pos - (ang:Right() * (width / 2))
					cam.Start3D2D(pos, ang, (1 / scale));
						surface.SetDrawColor(BoxColor)
						surface.DrawOutlinedRect(0, 0, (height * scale), (width * scale));
					cam.End3D2D();
				end
			end
		cam.End3D();
	end
	
	if (BH.CVARS.Bools["ESP: Show Money Printers"].cvar:GetBool()) then
		for k,v in pairs(ents.GetAll()) do
			if IsValid( v ) && BH.IsCloseEnough(v)  then
				if table.HasValue(BH.PrinterTable,v:GetClass()) then
					local Pl = v:GetPos():ToScreen()
					draw.SimpleText(v:GetClass(), BH.Font, Pl.x , Pl.y, Color(255, 255, 255, 255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
				end
			end
		end
	end
end

function BH.Chams()
	if (BH.CVARS.Bools["Chams"].cvar:GetBool()) then
		for _, ply in pairs( BH.GetPlayersByDistance( ) ) do
			if (ply != BH.ply() && IsValid( ply ) && ply:Alive() && ply:Health() > 0 && ply:Team() != TEAM_SPECTATOR && BH.IsCloseEnough(ply)) then
				local color = (BH.IsTTT and ply:IsTraitor( )) and Color( 200, 50, 50 ) or team.GetColor( ply:Team( ) );
				
				cam.Start3D( BH.ply():EyePos(), BH.ply():EyeAngles() );
					render.SuppressEngineLighting( true );
					render.SetColorModulation( color.r/255, color.g/255, color.b/255, 1 );
					render.MaterialOverride( BH.Mat );
					ply:DrawModel();
					render.SetColorModulation( BH.AddToColor( color.r, 150 )/255, BH.AddToColor( color.g, 150 )/255, BH.AddToColor( color.b, 150 )/255, 1 );
					
					if (IsValid( ply:GetActiveWeapon() )) then
						ply:GetActiveWeapon():DrawModel() 
					end
					
					if (BH.IsTTT && ply:IsTraitor()) then
						render.SetColorModulation( 1, 0, 0, 1 );
					else
						render.SetColorModulation( 1, 1, 1, 1 );
					end
					
					render.MaterialOverride();
					render.SetModelLighting( 4, color.r/255, color.g/255, color.b/255 );
					ply:DrawModel();
					render.SuppressEngineLighting( false );
				cam.End3D();
			end
		end
		
		for _, ent in pairs( ents.FindByClass( "ttt_c4" ) ) do
			cam.Start3D( BH.ply():EyePos(), BH.ply():EyeAngles() );
				render.SuppressEngineLighting( true );
				render.SetColorModulation( 1, 0, 0, 1 );
				render.MaterialOverride( BH.Mat );
				ent:DrawModel( );
				
				render.SetColorModulation( 1, 1, 1, 1 );
				render.MaterialOverride();
				render.SetModelLighting( BOX_TOP, 1, 1, 1 )
				ent:DrawModel();
					
				render.SuppressEngineLighting( false );
			cam.End3D();
		end
		
		if (BH.IsTTT) then
			for _, ent in pairs( ents.FindByClass( "prop_ragdoll" ) ) do
				if ( CORPSE.GetPlayerNick(ent, false) != false ) then
					cam.Start3D( BH.ply():EyePos(), BH.ply():EyeAngles() );
						render.SuppressEngineLighting( true );
						render.SetColorModulation( 1, 0.8, 0.5, 1 );
						render.MaterialOverride( BH.Mat );
						ent:DrawModel( );
						
						render.SetColorModulation( 1, 1, 1, 1 );
						render.MaterialOverride();
						render.SetModelLighting( BOX_TOP, 1, 1, 1 )
						ent:DrawModel();
							
						render.SuppressEngineLighting( false );
					cam.End3D();
				end
			end
		end
	end
end

function BH.AdminSpecs() --credits: hera
	for k, v in pairs(player.GetAll()) do
		if (IsValid(v:GetObserverTarget()) and v:GetObserverTarget():IsPlayer() and v:GetObserverTarget() == LocalPlayer()) then
			if(not table.HasValue(BH.spectators, v)) then
				table.insert(BH.spectators, v);
				if (BH.CVARS.Bools["Show Spectators"].cvar:GetBool()) then
					BH.PrintChat(Color( 200, 0, 0 ),v:Nick().." is now spectating you!")
					surface.PlaySound("buttons/combine_button1.wav")
				end
			end
		end
	end

	for k, v in pairs(BH.spectators) do
		if (not IsValid(v) or not IsValid(v:GetObserverTarget()) or not v:GetObserverTarget():IsPlayer() or (v:GetObserverTarget() ~= LocalPlayer())) then
			table.remove(BH.spectators, k);
				if (BH.CVARS.Bools["Show Spectators"].cvar:GetBool()) then
				BH.PrintChat(Color( 0, 200, 0 ),v:Nick().." is no longer spectating you!")
			end
		end
	end
	if (BH.CVARS.Bools["Show Admins Connect"].cvar:GetBool()) then
		for k, v in pairs(player.GetAll()) do
			if (v:IsAdmin() and not table.HasValue(BH.Admins, v)) then
				table.insert(BH.Admins, v);
				BH.PrintChat( Color( 0, 200, 255 ), "Admin " .. v:Nick() .. " has joined!" )
				surface.PlaySound("buttons/blip1.wav");
			end
		end
	end
end

function BH.PlayerDeath( ply )
	BH.PrintChat( Color( 200, 200, 255 ), ply:Nick().." has died!" );
end

timer.Create( BH.TimerName, 0.25, 0, function( )	
	if (!BH.IsTTT || GetRoundState() != 3) then 
		table.Empty( BH.DeadPlayers );
		return;
	end
	BH.RandomAimSpot = table.Random(BH.RandomAimSpots);
	
	for _, ply in pairs( BH.players() ) do
		if ((!ply:Alive() || ply:Health() <= 0) && !table.HasValue( BH.DeadPlayers, ply )) then
			table.insert( BH.DeadPlayers, ply );
			BH.PlayerDeath( ply );
		end
	end
end )

function BH.TraitorDetector()
	if (!BH.IsTTT) then return end
	
	if (GetRoundState() == 2) then
		for _, wep in pairs(ents.GetAll()) do
			if (wep.CanBuy && wep:IsWeapon() && !table.HasValue(BH.TWeaponsFound, wep:EntIndex())) then
				table.insert( BH.TWeaponsFound, wep:EntIndex() )
			end
		end
	end
	
	if (GetRoundState() != 3 && GetRoundState() != 2) then
		RunConsoleCommand(BH.RandomPrefix.."_esp_skeleton", "0");  --I have to stop skeleton esp because errors would occur on respawn
		table.Empty( BH.Traitors );
		table.Empty( BH.TWeaponsFound );
		return;
	end
	
	for _, wep in pairs(ents.GetAll()) do
		if (wep:IsWeapon() && wep.CanBuy && IsValid( wep:GetOwner() ) && wep:GetOwner():IsPlayer() && !table.HasValue( BH.TWeaponsFound, wep:EntIndex() )) then
			local ply = wep:GetOwner();
			table.insert( BH.TWeaponsFound, wep:EntIndex() );
			
			if (!ply:IsDetective()) then
				if (!table.HasValue(BH.Traitors, ply)) then
					table.insert(BH.Traitors, ply);
				end
				if (ply != BH.ply() && !BH.ply():IsTraitor() && BH.CVARS.Bools["Traitor Detector"].cvar:GetBool()) then
					BH.PrintChat( Color( 255, 150, 150 ), ply:Nick(), Color( 255, 255, 255 ), " is a ", Color( 255, 50, 50 ), "traitor: ", Color( 200, 120, 50 ), wep:GetPrintName() or wep:GetClass() );
				end
			end
		end
	end
end


function BH.AddHook( hookname, name, func )
	table.insert( BH.RandomHooks.hook, hookname );
	table.insert( BH.RandomHooks.name, name );
	hook.Add( hookname, name, func );
end

function BH.Menu( )
	local UsedCVARS = { };
		
	local Panel = vgui.Create( "DFrame" );
	Panel:SetSize( 500, 300 );
	Panel:SetPos( ScrW()/2-Panel:GetWide()/2, ScrH()/2-Panel:GetTall()/2 );
	Panel:SetTitle( "Blue Hawk - Fasthawk Edition" );
	Panel:MakePopup();
	
	local SettingsSheet = vgui.Create( "DPropertySheet", Panel );
	SettingsSheet:SetPos( 0, 23 );
	SettingsSheet:SetSize( SettingsSheet:GetParent():GetWide(), SettingsSheet:GetParent():GetTall() - 23 );
	
	local MainPanel = vgui.Create( "DPanel", Panel );
	MainPanel:SetPos( 0, 0 );
	MainPanel:SetSize( MainPanel:GetParent():GetWide(), MainPanel:GetParent():GetTall() - 23 );
	MainPanel.Paint = function() end;
	
	local AimPanel = vgui.Create( "DPanel", Panel );
	AimPanel:SetPos( 0, 0 );
	AimPanel:SetSize( MainPanel:GetParent():GetWide(), MainPanel:GetParent():GetTall() - 23 );
	AimPanel.Paint = function() end;
	AimPanel:SetVisible( false );
	
	local ESPPanel = vgui.Create( "DPanel", Panel );
	ESPPanel:SetPos( 0, 0 );
	ESPPanel:SetSize( MainPanel:GetParent():GetWide(), MainPanel:GetParent():GetTall() - 23 );
	ESPPanel.Paint = function() end;
	ESPPanel:SetVisible( false );
	
	local MiscPanel = vgui.Create( "DPanel", Panel );
	MiscPanel:SetPos( 0, 25 );
	MiscPanel:SetSize( MainPanel:GetParent():GetWide(), MainPanel:GetParent():GetTall() - 23 );
	MiscPanel.Paint = function() end;
	MiscPanel:SetVisible( false );
	
	SettingsSheet:AddSheet("General", MainPanel, "gui/silkicons/application_view_tile", false, false, "General settings");
	SettingsSheet:AddSheet("Aimbot", AimPanel, "gui/silkicons/bomb", false, false, "Aimbot settings");
	SettingsSheet:AddSheet("ESP/Chams", ESPPanel, "gui/silkicons/wrench", false, false, "ESP/Chams settings");
	SettingsSheet:AddSheet("Misc", MiscPanel, "gui/silkicons/box", false, false, "Misc settings");
	--==Main Panel==--
	local Label = vgui.Create( "DLabel", MainPanel );
	Label:SetPos( 10, 5 );
	Label:SetColor( Color( 255, 255, 255, 255 ) );
	Label:SetText( "Settings" );
	Label:SizeToContents();
	
	local List = vgui.Create( "DPanelList", MainPanel );
	List:SetPos( 10, 20 );
	List:SetSize( 200, 200 );
	List:SetSpacing( 5 );
	List:EnableHorizontal( false );
	List:EnableVerticalScrollbar( true );
	List:SetPadding( 5 );
	function List:Paint()
		draw.RoundedBox( 4, 0, 0, List:GetWide(), List:GetTall(), Color( 0, 0, 0, 150 ) );
	end
	
	table.sort( BH.CVARS.Bools, BH.TableSortByAsc );
	
	for name, base in pairs(BH.CVARS.Bools) do
		if (base.OnMenu && base.main) then
			local CheckBox = vgui.Create( "DCheckBoxLabel" );
			CheckBox:SetText( name );
			CheckBox:SetConVar( base.cvar:GetName() );
			CheckBox:SetValue( base.cvar:GetBool() );
			CheckBox:SizeToContents();
			List:AddItem( CheckBox );
			table.insert( UsedCVARS, base );
		end
	end
	--==Aimbot==--
	Label = vgui.Create( "DLabel", AimPanel );
	Label:SetPos( 10, 5 );
	Label:SetColor( Color( 255, 255, 255, 255 ) );
	Label:SetText( "Aimbot settings" );
	Label:SizeToContents();
	
	Label = vgui.Create( "DLabel", AimPanel );
	Label:SetPos( 275, 5 );
	Label:SetColor( Color( 255, 255, 255, 255 ) );
	Label:SetText( "Closet settings" );
	Label:SizeToContents();
	
	local List = vgui.Create( "DPanelList", AimPanel );
	List:SetPos( 10, 20 );
	List:SetSize( 200, 200 );
	List:SetSpacing( 5 );
	List:EnableHorizontal( false );
	List:EnableVerticalScrollbar( true );
	List:SetPadding( 5 );
	function List:Paint()
		draw.RoundedBox( 4, 0, 0, List:GetWide(), List:GetTall(), Color( 0, 0, 0, 150 ) );
	end
	
	for name, base in pairs(BH.CVARS.Bools) do
		if (base.OnMenu && !base.main && string.find( base.cvar:GetName(), "aim" )) then
			local CheckBox = vgui.Create( "DCheckBoxLabel" );
			CheckBox:SetText( name );
			CheckBox:SetConVar( base.cvar:GetName() );
			CheckBox:SetValue( base.cvar:GetBool() );
			CheckBox:SizeToContents();
			List:AddItem( CheckBox );
			table.insert( UsedCVARS, base );
		end
	end
	
	local FOVSlider = vgui.Create( "DNumSlider", AimPanel );
	FOVSlider:SetPos( 275, -15 );
	FOVSlider:SetSize( 150, 100 );
	FOVSlider:SetText( "Max Angle" );
	FOVSlider:SetMin( 0 );
	FOVSlider:SetMax( 180 );
	FOVSlider:SetDecimals( 0 );
	FOVSlider:SetConVar( BH.RandomPrefix.."_aimbot_max_angle" );
	FOVSlider.Paint = function()
		draw.RoundedBox( 4, 0, 36, FOVSlider:GetWide(), 25, Color( 0, 0, 0, 150 ) );
	end
	
	local DISSlider = vgui.Create( "DNumSlider", AimPanel );
	DISSlider:SetPos( 275, 45 );
	DISSlider:SetSize( 150, 100 );
	DISSlider:SetText( "Aim Distance" );
	DISSlider:SetMin( 0 );
	DISSlider:SetMax( 5000 );
	DISSlider:SetDecimals( 0 );
	DISSlider:SetConVar( BH.RandomPrefix.."_aimbot_max_distance" );
	DISSlider.Paint = function()
		draw.RoundedBox( 4, 0, 36, DISSlider:GetWide(), 25, Color( 0, 0, 0, 150 ) );
	end
	--==ESP==--
	Label = vgui.Create( "DLabel", ESPPanel );
	Label:SetPos( 10, 5 );
	Label:SetColor( Color( 255, 255, 255, 255 ) );
	Label:SetText( "ESP/Chams settings" );
	Label:SizeToContents();
	
	Label = vgui.Create( "DLabel", ESPPanel );
	Label:SetPos( 275, 5 );
	Label:SetColor( Color( 255, 255, 255, 255 ) );
	Label:SetText( "ESP/Chams distance" );
	Label:SizeToContents();
	
	List = vgui.Create( "DPanelList", ESPPanel );
	List:SetPos( 10, 20 );
	List:SetSize( 200, 200 );
	List:SetSpacing( 5 );
	List:EnableHorizontal( false );
	List:EnableVerticalScrollbar( true );
	List:SetPadding( 5 );
	function List:Paint()
		draw.RoundedBox( 4, 0, 0, List:GetWide(), List:GetTall(), Color( 0, 0, 0, 150 ) );
	end
	
	for name, base in pairs(BH.CVARS.Bools) do
		if (base.OnMenu && !base.main && (string.find( base.cvar:GetName(), "esp" ) || string.find( base.cvar:GetName(), "cham" ))) then
			local CheckBox = vgui.Create( "DCheckBoxLabel" );
			CheckBox:SetText( name );
			CheckBox:SetConVar( base.cvar:GetName() );
			CheckBox:SetValue( base.cvar:GetBool() );
			CheckBox:SizeToContents();
			List:AddItem( CheckBox );
			table.insert( UsedCVARS, base );
		end
	end
	
	local ESPSlider = vgui.Create( "DNumSlider", ESPPanel );
	ESPSlider:SetPos( 275, -15 );
	ESPSlider:SetSize( 150, 100 );
	ESPSlider:SetText( "ESP: Distance" );
	ESPSlider:SetMin( 0 );
	ESPSlider:SetMax( 15000 );
	ESPSlider:SetDecimals( 0 );
	ESPSlider:SetConVar( BH.RandomPrefix.."_esp_distance" );
	ESPSlider.Paint = function()
		draw.RoundedBox( 4, 0, 36, ESPSlider:GetWide(), 25, Color( 0, 0, 0, 150 ) );
	end
	--==MISC==--
	Label = vgui.Create( "DLabel", MiscPanel );
	Label:SetPos( 10, 5 );
	Label:SetColor( Color( 255, 255, 255, 255 ) );
	Label:SetText( "Misc settings" );
	Label:SizeToContents();
	
	Label = vgui.Create( "DLabel", MiscPanel );
	Label:SetPos( 275, 5 );
	Label:SetColor( Color( 255, 255, 255, 255 ) );
	Label:SetText( "Speedhack Speed" );
	Label:SizeToContents();
	
	List = vgui.Create( "DPanelList", MiscPanel );
	List:SetPos( 10, 20 );
	List:SetSize( 200, 200 );
	List:SetSpacing( 5 );
	List:EnableHorizontal( false );
	List:EnableVerticalScrollbar( true );
	List:SetPadding( 5 );
	function List:Paint()
		draw.RoundedBox( 4, 0, 0, List:GetWide(), List:GetTall(), Color( 0, 0, 0, 150 ) );
	end
	
	for name, base in pairs(BH.CVARS.Bools) do
		if (base.OnMenu && !table.HasValue( UsedCVARS, base )) then
			local CheckBox = vgui.Create( "DCheckBoxLabel" );
			CheckBox:SetText( name );
			CheckBox:SetConVar( base.cvar:GetName() );
			CheckBox:SetValue( base.cvar:GetBool() );
			CheckBox:SizeToContents();
			List:AddItem( CheckBox );
		end
	end

	local SP1Slider = vgui.Create( "DNumSlider", MiscPanel );
	SP1Slider:SetPos( 275, -15 );
	SP1Slider:SetSize( 150, 100 );
	SP1Slider:SetText( "Speedhack Speed" );
	SP1Slider:SetMin( 0 );
	SP1Slider:SetMax( 15 );
	SP1Slider:SetDecimals( 0 );
	SP1Slider:SetConVar( BH.RandomPrefix.."_spe1ed" );
	SP1Slider.Paint = function()
		draw.RoundedBox( 4, 0, 36, SP1Slider:GetWide(), 25, Color( 0, 0, 0, 150 ) );
	end
end

CreateClientConVar("hawk_pkill_speed", 100)
CreateClientConVar("hawk_pkill_prop", "models/props_c17/furnitureStove001a.mdl")
CreateClientConVar("hawk_pkill_remover", 0.5)

local function propkill()
	local atttime = 0
	if LocalPlayer():GetActiveWeapon():GetClass() != "weapon_physgun" then
		local lastwep = LocalPlayer():GetActiveWeapon()
		RunConsoleCommand("use", "weapon_physgun")
		atttime = 0.2
		timer.Simple(.3, function()
		RunConsoleCommand("use", lastwep:GetClass())
		end)
	end
	hook.Add( "CreateMove", "PKill", function(cmd)
		cmd:SetMouseWheel(GetConVarNumber("hawk_pkill_speed"))
	end)
	RunConsoleCommand("gm_spawn", GetConVarString("hawk_pkill_prop"))
	timer.Simple(atttime, function()
		RunConsoleCommand("+attack")
	end)

	timer.Simple(atttime+.1, function()
		RunConsoleCommand("-attack")
	end)
	timer.Simple(GetConVarNumber("hawk_pkill_remover"), function()
		hook.Remove("CreateMove", "PKill")
		RunConsoleCommand("undo")
	end )
end

concommand.Add("hawk_pkill", propkill)

 // speed hack
BH.require("col3")
 
T1S = GetConVar('host_timescale')
C1H = GetConVar('sv_cheats')
TH1 = GetConVar('thirdperson')
LK1 = GetConVar('sv_kickerrornum')
FB1 = GetConVar('mat_fullbright')
 
spe1edon = function()
C1H:SetValue(BH.CVARS.Numbers["Spe1edha1ck"].cvar:GetFloat())
T1S:SetValue(BH.CVARS.Numbers["Spe1edha1ck"].cvar:GetFloat())
end
 
spe1edoff = function()
T1S:SetValue(1.0)
C1H:SetValue(0)
end

brighton = function()
C1H:SetValue(1.0)
FB1:SetValue(1.0)
end
 
brightoff = function()
FB1:SetValue(0.0)
C1H:SetValue(0)
end

concommand.Add("hawk_brighton", brighton)
concommand.Add("hawk_brightoff", brightoff)

th1rdpersonON = function()
RunConsoleCommand( "thirdperson" ); var2 = true; end;
 
th1rdpersonOFF = function()
RunConsoleCommand( "firstperson" ); var2 = false; end;

forceluakick = function()
LK1:SetValue(0.0)
BH.Print(true,orange,"Forced CVAR sv_kickerrornum to "..LK1:GetInt())
surface.PlaySound("buttons/blip1.wav")
end

 
concommand.Add("+1122", spe1edon)
concommand.Add("-1122", spe1edoff)
 
concommand.Add("+1122", spe1edon)
concommand.Add("-1122", spe1edoff)

concommand.Add("hawk_thirdperson", th1rdpersonON)
concommand.Add("hawk_thirdpersonoff", th1rdpersonOFF)

concommand.Add("forceluakick", forceluakick)

function BH.UpdateMenu()
	local Panel = vgui.Create( "DFrame" );
	Panel:SetSize( 800, 600 );
	Panel:SetPos( ScrW()/2-Panel:GetWide()/2, ScrH()/2-Panel:GetTall()/2 );
	Panel:SetTitle( "Blue Bot - Notice" );
	Panel:MakePopup();
	
	local Label = vgui.Create( "DLabel", Panel );
	Label:SetColor( Color( 255, 255, 255, 255 ) );
	Label:SetFont( "DermaLarge" );
	Label:SetText( "Your version is outdated! "..BH.Version );
	Label:SizeToContents();
	Label:SetPos( Label:GetParent():GetWide()/2-Label:GetWide()/2-5, 50 );
	Label.Paint = function()
		Label:SetColor( Color( 255, 255 - (math.sin( CurTime() * 4 ) * 255), 255 - (math.sin( CurTime() * 4 ) * 255), 255 ) );
	end
	
	local HTML = vgui.Create( "HTML", Panel );
	HTML:OpenURL( "http://bluekirbygmod.googlecode.com/svn/trunk/Blue%20Bot/changelog.txt" );
	HTML:SetSize( HTML:GetParent():GetWide() - 50, HTML:GetParent():GetTall() - 160 );
	HTML:SetPos( 25, 100 )
	HTML.Paint = function()
		surface.SetDrawColor( Color( 255, 255, 255, 255 ) );
		surface.DrawRect( 0, 0, HTML:GetWide(), HTML:GetTall() );
	end
	
	local Button = vgui.Create( "DButton", Panel );
	Button:SetText( "Save" );
	Button:SetSize( Button:GetParent():GetWide() - 50, 25 );
	Button:SetPos( 25, Button:GetParent():GetTall() - 30 );
	Button.DoClick = function()
		HTML:SetVisible( false );
		Panel:SetSize( 400, 150 );
		Panel:SetPos( ScrW()/2-Panel:GetWide()/2, ScrH()/2-Panel:GetTall()/2 );
		Label:SetText( "Saved to data/bluebotv"..BH.V..".txt" );
		Label:SizeToContents();
		Label:SetPos( Label:GetParent():GetWide()/2-Label:GetWide()/2-5, 50 );
		file.Write( "bluebotv"..BH.V..".txt", BH.LatestVersion );
	end
end

BH.Init();
//hooks
BH.AddHook( "RenderScreenspaceEffects" , BH.RandomString( 0, true, true ), BH.Chams );
BH.AddHook( "Think", BH.RandomString( 0, true, true ), BH.Aimbot );
BH.AddHook( "Think", BH.RandomString( 0, true, true ), BH.TraitorDetector );
BH.AddHook( "Think", BH.RandomString( 0, true, true ), BH.AdminSpecs );
BH.AddHook( "CreateMove", BH.RandomString( 0, true, true ), BH.CreateMove );
BH.AddHook( "CalcView", BH.RandomString( 0, true, true ), BH.NoVisualRecoil );
BH.AddHook( "HUDPaint", BH.RandomString( 0, true, true ), BH.ESP );
BH.AddHook( "CreateMove", BH.RandomString( 0, true, true ), Mouse );
BH.AddHook( "CalcView", BH.RandomString( 0, true, true ), NormaliziseView );
BH.AddHook( "PlayerConnect", BH.RandomString( 0, true, true ), PlayerConnect );

concommand.Add( "1122", function( ply, cmd, args )  --PANIC!
	for i = 1, #BH.RandomHooks.hook do
		hook.Remove( BH.RandomHooks.hook[i], BH.RandomHooks.name[i] );
		BH.Print( true, true, Color( 255, 255, 255 ), "Unhooked "..BH.RandomHooks.hook[i].." using name "..BH.RandomHooks.name[i] );
	end
	concommand.Remove( "+1122" ); --speed
	concommand.Remove( "-1122" );
	concommand.Remove( "1122" ); --panic
	concommand.Remove( "1133" ); --menu
	concommand.Remove( "+1144" ); --aimon
	concommand.Remove( "-1144" );
	timer.Destroy( BH.TimerName );
	BH.Unloaded = true;
	BH.Print( true, true, Color( 255, 255, 255 ), "Unloaded successfully!" );
end );

concommand.Add( "1133", BH.Menu );
concommand.Add( "+1144", function( ply, cmd, args )
	BH.AimbotKeyDown = true;
	
	BH.Aimbot();
end );

concommand.Add( "-1144", function( ply, cmd, args ) 
	BH.AimbotKeyDown = false;
end );
----------------------------------------------------
//Toggle command
local showing = true

concommand.Add("ShowEnts", function()
	if showing then
		showing = false
	else
		showing = true
	end
end)

//Everything menu related
local EntsToShow = {}
local OtherEnts = {}

concommand.Add("_ents", function(ply, cmd, args)
	function Reload(startX, startY)
		table.Empty(OtherEnts)
		for k,v in pairs(ents.GetAll()) do
			local addToAllEnts = true
			
			for i,p in pairs(EntsToShow) do
				if p == v:GetClass() then
					addToAllEnts = false
				end
			end
			
			for i,p in pairs(OtherEnts) do
				if p == v:GetClass() then
					addToAllEnts = false
				end
			end
			
			if addToAllEnts then
				table.insert(OtherEnts, v:GetClass())
			end
		end

		local main = vgui.Create( "DFrame" )
		main:SetSize( 400, 250 )
		if startX and startY then
			main:SetPos(startX, startY)
		else
			main:Center()
		end
		main:SetTitle( "" )
		main:SetVisible( true )
		main:SetDraggable( true )
		main:ShowCloseButton( true )
		main:MakePopup()
		main.Paint = function()
			draw.RoundedBox( 8, 0, 0, main:GetWide(), main:GetTall(), Color( 0, 0, 0, 150 ) )
		end
		
		DermaList = vgui.Create( "DPanelList", main	)
		DermaList:SetPos( 25,25 )
		DermaList:SetSize( 700, 500 )
		DermaList:SetSpacing( 75 )
		DermaList:EnableHorizontal( false )
		DermaList:EnableVerticalScrollbar( true )
		
		local SelectedEnts = vgui.Create("DListView")
		SelectedEnts:SetSize(150, 200)
		SelectedEnts:SetPos(0, 0)
		SelectedEnts:SetMultiSelect(false)
		SelectedEnts:AddColumn("Ents to show")
		for k,v in pairs(EntsToShow) do
			SelectedEnts:AddLine(v)
		end
		SelectedEnts.DoDoubleClick = function(parent, index, list)
			table.remove(EntsToShow, index)
			main:Close()
			local x, y = main:GetPos()
			Reload(x, y)
		end
		DermaList:Add(SelectedEnts)
		
		local AllEnts = vgui.Create("DListView")
		AllEnts:SetSize(150, 200)
		AllEnts:SetPos(200, 0)
		AllEnts:SetMultiSelect(false)
		AllEnts:AddColumn("Ents not to show")
		for k,v in pairs(OtherEnts) do
			AllEnts:AddLine(v)
		end
		AllEnts.DoDoubleClick = function(parent, index, list)
			table.insert(EntsToShow, OtherEnts[index])
			main:Close()
			local x, y = main:GetPos()
			Reload(x, y)
		end
		DermaList:Add(AllEnts)
	end
	Reload()
end)

//Actually drawing information
hook.Add("HUDPaint", "ShowEnts", function()
	if showing then
		for k,v in pairs(ents.GetAll()) do
			local drawing = false
			
			for i,p in pairs(EntsToShow) do
				if v:GetClass() == p then
					drawing = true
				end
			end
			
			if drawing then
				local stuff = v:GetPos():ToScreen()
				
				surface.SetTextPos( stuff.x - 15, stuff.y ) 
				surface.SetFont("default")
				local text = v:GetClass()
				surface.DrawText( text )
				surface.SetTextColor( 20, 200, 100, 255 )

				
				local Width, Height = surface.GetTextSize(text)
			end
		end
	end
end)


----------shittestfunctionsbelow-------------